class UserController < ApplicationController
  before_filter :login_required

  def index
    @users = []
  end

  def post
    User.update(params[:user].keys, params[:user].values)
    flash[:notice] = 'Saved'
    redirect_to(:action => "index")
  end

  def delete
    rv = User.destroy(params[:id])
    if rv == 0
      render(:text=>"This user does not exist")
    else
      render(:text=>"$('notice').innerHTML= 'User has been deleted';var el=$('tr#{params[:id]}');new Effect.Fade(el);")
    end
  end

  def toggle
    return if not session['user']
    session['user'].toggle
  end

  def refresh_project_list
    user = User.find(session['user'])
    render(:partial=>"user/project_list", :locals=>{:user=>user})
  end

end
